package com.lanou3g.ptp.remind.entity;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lanou3g.ptp.taskstudent.service.TaskStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
public class EvaluationJob {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Reference
    private TaskStudentService taskStudentService;

    @Value("REMIND-EVALUATION-")
    private String REDIS_EVALUATIONREMIND_KEY_PREFIX;


    public void evaluationRemind(Long taskId){

        ArrayList<Long> students = taskStudentService.findByTaskId(taskId);

        String key = REDIS_EVALUATIONREMIND_KEY_PREFIX + taskId;

        for (Long student : students) {

            redisTemplate.opsForValue().set(key,student.toString());

        }


    }
}
